﻿{extend name="public:base" /}

{block name="content"}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <form method="post">
                        <div class="box-item">
                            <div class="form-group row"><label class="col-sm-1 col-form-label">名称</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="name" placeholder="请输入名称" value="{$info.name}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <input type="hidden" name="id" value="{:input('id')}" style="display: none">

                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button type="button" class="btn btn-w-m btn-default back-page">返回</button>
                                <button type="button" class="btn btn-w-m btn-primary ajax-post">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name='js'}
<script type="text/javascript" src="__PLUG__/kindeditor/kindeditor-all.js"></script>
<script>
    <!-- 实例化编辑器 -->
    initKindEditor('editor_id');

    function updateImg() {
        // $("#upload_img").click(function () {
        $("#img_file").trigger("click");
        // })

        $('#img_file').change(function () {
            var pic = $(this)[0].files[0];
            var formData = new FormData();
            var url = "{:url('UploadFile/uploadPicture',array('session_id'=>session_id()))}";
            formData.append('download', pic);
            $.ajax({
                url: url,
                type: "post",
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    if (data.status == 1) {
                        //上传成功
                        var id = data.id;
                        var path = data.path;
                        console.log(data);
                        return;

                        $('#img').val(id);
                        $('#upload_img').attr('src', path);
                    } else {
                        layer.msg(data.info);
                    }
                }
            });
        });
    }


</script>
{/block}
